<%@ page language="java" import="java.util.*, com.zjut.an.news.manager.*, com.zjut.an.news.dao.*, com.zjut.zs.applyview.manager.*, com.zjut.zs.applyview.dao.*, 
com.zjut.zs.user.manager.*, com.zjut.zs.user.dao.*,com.zjut.zs.userstatus.manager.*, com.zjut.zs.userstatus.dao.*,
com.zjut.zs.zxlb.manager.*, com.zjut.zs.shhd.manager.*, com.zjut.zs.hjqk.manager.*, 
com.zjut.zs.zxlb.dao.*, com.zjut.zs.shhd.dao.*, com.zjut.zs.hjqk.dao.*, 
com.zjut.an.webclass.manager.*, com.zjut.an.webclass.dao.*,com.zjut.an.util.tools.*,com.zjut.an.util.system.*,
com.zjut.an.config.manager.*, com.zjut.an.config.dao.*, com.zjut.zs.util.tools.*" pageEncoding="utf-8"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%=Config.webname%></title>
	<link href="../plugins/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
	<link href="../plugins/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	<link href="../plugins/assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
	<link href="../plugins/assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
	<link href="../plugins/assets/css/style.css" rel="stylesheet" type="text/css"/>
	<link href="../plugins/assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
	<link href="../plugins/assets/css/plugins.css" rel="stylesheet" type="text/css"/>
	<link rel="shortcut icon" href="favicon.ico" />
	
	<!-- 引入 ECharts 文件 -->
</head>
<%
AnConfigManager anconfig = (AnConfigManager) SpringContextUtil.getBean("AnConfigManager");
ZsUserManager umanager = (ZsUserManager) SpringContextUtil.getBean("ZsUserManager");
ZsUserStatusManager smanager = (ZsUserStatusManager) SpringContextUtil.getBean("ZsUserStatusManager");
ZsApplyViewManager manager = (ZsApplyViewManager) SpringContextUtil.getBean("ZsApplyViewManager");
ZsZxlbManager zmanager = (ZsZxlbManager) SpringContextUtil.getBean("ZsZxlbManager");
ZsShhdManager hmanager = (ZsShhdManager) SpringContextUtil.getBean("ZsShhdManager");
ZsHjqkManager jmanager = (ZsHjqkManager) SpringContextUtil.getBean("ZsHjqkManager");

if ("do".equals(request.getParameter("action"))) {	
	try {
		List userlist = umanager.getDatas();
		int j=0;
		for (j=0;j<userlist.size();j++) {
			ZsUser user= (ZsUser)userlist.get(j);
			
			ZsUserStatus userStatus = new ZsUserStatus();
			userStatus.setZsUser(user);
			userStatus = (ZsUserStatus) smanager.getDataByInstance(1, 1, null, null, userStatus).getObjects().get(0);
			
			StringBuffer zsZxlbs = new StringBuffer();
			List list = zmanager.getDataByUser(user);
			for(int i=0; i<list.size(); i++) {
				ZsZxlb zxlb = (ZsZxlb)list.get(i);
				zsZxlbs.append("["+zxlb.getZxType()+"."+zxlb.getZxName()+"."+zxlb.getZxJb()+"."+zxlb.getZxDate()+"."+zxlb.getZxOrg()+"."+zxlb.getZxDj()+"] ");
			}
			System.out.println("####### zxlb:"+zsZxlbs.toString());
			userStatus.setZsZxlb(zsZxlbs.toString());
			smanager.updateData(userStatus);
			
			StringBuffer zsShhds = new StringBuffer();
			list = hmanager.getDataByUser(user);
			for(int i=0; i<list.size(); i++) {
				ZsShhd shhd = (ZsShhd)list.get(i);
				zsShhds.append("["+shhd.getHdName()+"."+shhd.getHdJs()+"."+shhd.getHdDateStart()+"-"+shhd.getHdDateEnd()+"."+shhd.getHdOrg()+"] ");
			}
			System.out.println("####### shhd:"+zsShhds.toString());
			userStatus.setZsShhd(zsShhds.toString());
			smanager.updateData(userStatus);
			
			StringBuffer zsHjqks = new StringBuffer();
			list = jmanager.getDataByUser(user);
			for(int i=0; i<list.size(); i++) {
				ZsHjqk hjqk = (ZsHjqk)list.get(i);
				zsHjqks.append("["+hjqk.getHjName()+"."+hjqk.getHjJb()+"."+hjqk.getHjDate()+"."+hjqk.getHjOrg()+"."+hjqk.getHjDj()+"] ");
			}
			System.out.println("####### hjqk:"+zsHjqks.toString());
			userStatus.setZsHjqk(zsHjqks.toString());
			smanager.updateData(userStatus);
		}
		
		out.print("<script>alert('计算完成，共同步"+j+"个数据');</script>");
	} catch (Exception e) {
		e.printStackTrace();
		out.print("<script>alert('计算出错，请检查');</script>");
	}
	
}

 %>
<body class="page-header-fixed">
	<div class="clearfix"></div>
	<div class="page-container">
		<div class="page-content">
			<div class="row">
				<div class="col-md-12">
					<ul class="page-breadcrumb breadcrumb">
					  <li>
						  <i class="fa fa-home"></i>
						  <a href="index.jsp">首页</a> 
						  <i class="fa fa-angle-right"></i>
						</li>
						<li><a href="#">测试成绩计算</a></li>
					</ul>
				</div>
			</div>
			<div class="row">
				<div class="col-md-12">
				
					<form id="ff" Config="form" class="form-horizontal" action="zsUserTestNumCount.jsp" method="post">  
					<div class="formbody">   
						<ul class="forminfo">
							<li><label>修正报考专项信息，请谨慎操作。报名数据量较大，计算总成绩过程需要时间，请耐心等待。</label></li>
							<li>
							<input id="action" name="action" type="text" class="dfinput" value="do"  style="display:none;"/>
							<button type="submit" class="btn btn-primary btn-sm">开始计算 </button>  
							</li>
						</ul>
					</div>
		                
		            </form> 

				</div>
			</div>
		</div>
	</div>
	<script src="../plugins/assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
	<script src="../plugins/assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>    
	<script src="../plugins/assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
	<script src="../plugins/assets/plugins/bootstrap-hover-dropdown/twitter-bootstrap-hover-dropdown.min.js" type="text/javascript" ></script>
	<script src="../plugins/assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
	<script src="../plugins/assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>  
	<script src="../plugins/assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
	<script src="../plugins/assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript" ></script>
	<script src="../plugins/assets/scripts/app.js"></script>  
	
	<script src="../plugins/assets/plugins/jquery-validation/dist/jquery.validate.js" type="text/javascript"></script>
	<script src="js/publicManager.js" type="text/javascript" charset="utf-8"></script>  
	
	<script>
	jQuery(document).ready(function() {       
		   App.init();
		});
	
		
	</script>
</body>
</html>